#pragma once

#include "d3dbase.h"
#include "d3dmath.h"

namespace D3DUtil {

class Spriter {
	struct SpriteVertex
	{
		D3DMath::Vec3 pos;
		unsigned int diffuse;
		float u,v;
	};
	enum {SPRITEFVF = D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1};
	enum {MAXBUFFERSIZE = 2048};
	SpriteVertex *buffer;
	int idx;
public:
	explicit Spriter();
	~Spriter();

	void Begin(LPDIRECT3DTEXTURE9 tex);
	void DrawCentered(float x, float y, float z, float width, float height, unsigned int diffuse = 0xFFFFFFFF);
	void Draw(float x, float y, float z, float width, float height, unsigned int diffuse = 0xFFFFFFFF);
	void DrawSubUV(float x, float y, float z, float width, float height, float u1, float v1, float u2, float v2, unsigned int diffuse = 0xFFFFFFFF);
	void End();
};

}  // namespace